package com.tianqu.tms.www.car.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tianqu.tms.core.base.TmsAction;
import com.tianqu.tms.core.base.UserContext;
import com.tianqu.tms.core.util.TmsConstants;
import com.tianqu.tms.www.car.actionform.CarImgInputActionForm;
import com.tianqu.tms.www.car.viewhelper.CarStockModifyViewhelper;

public class CarImageInputAction extends TmsAction {
	
	private static final String IMGTYPE = "imgType";//1：车辆整体图片
	private static final String IMGKEY = "imgKey";//图片位置key
	private static final String LICENSEPLATE = "licensePlate";
	@Override
	protected ActionForward doAction(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response,
			UserContext uc) throws Exception {
		//从前台获取一个文件名 需要进行check  得到车辆ID 图片key12345566 图片type 1
		CarImgInputActionForm imgForm = (CarImgInputActionForm)form;

		//获取vin码在页面设置一个隐藏值用于跳转
		CarStockModifyViewhelper viewhelp = (CarStockModifyViewhelper)uc.getAttribute(TmsConstants.VIEWHELP);
		String licensePlate = (String)uc.getAttribute(LICENSEPLATE);
		if(licensePlate != null && !"".equals(licensePlate)){
			viewhelp.setLicensePlate(licensePlate);//将车牌号重加入viewhelp中
		}	
		//将vin码放到viewhelp中 跳转读取
		request.setAttribute(TmsConstants.VIEWHELP, viewhelp);
				
		return mapping.findForward(TmsConstants.SUCCESS);
	}

}
